Simple database example

What makes WBSP really different from programming languages and other hypertext preprocessors is it's way of dealing with databases. WBSP can work with wide range of databases that are supported by MS Jet Engine, DAO and ADO objects and ODBC. In our examples we use MS Access database biblio.mdb that can be downloaded from our server.

Download file bibliomdb.zip from our server and unpack it in your document root of your web server and create file biblio.wbsp in same directory with following content: 

[FormFields]
WB_Command=q
WB_Basename=biblio.mdb
WB_Rcdset=titles
WB_TempName=$default$

Access the file with your web server's URL followed by /biblio.wbsp. On your local web server (located on same computer as your browser) the address should be http://localhost/biblio.wbsp or http://127.0.0.1/biblio.wbsp. If WBSP is installed correctly and the server is configured correctly, your browser should receive something like this:

 

Title Year Published ISBN PubID AU_ID
McGraw-Hill's Encyclopedia of Networking & Telecommunications 2001 0072120053 10 10
Microsoft SMS Installer 2000 0072124474 10 9
Windows 2000 Iis 5.0 : A Beginner's Guide 2001 0072133724 9 9
Windows Nt Security Handbook 1996 0078822408 10 11
Microsoft Internet Information Server 4: the Complete Reference 1998 0078824575 10 10
Non-Designer's Scan and Print Book, The 1999 0201353946 1 2
Real World Adobe InDesign 1.5 2000 0201354780 1 1
HTML 4 for the World Wide Web: Visual Quickstart Guide 2000 0201354934 1 6
Real World Freehand 7 1997 0201688875 1 1
Netscape 3 for Macintosh Visual Quickstart Guide 1996 0201694085 1 6
Kai's Power Tools 3 for Windows Visual Quickstart Guide 1997 0201696681 1 2
InDesign 1.0/1.5 for Macintosh and Windows: Visual QuickStart Guide 2000 0201710366 1 2
Fireworks 4 for Windows and Macintosh Visual Quickstart Guide 2001 0201731339 1 2
Macromedia FreeHand 10 for Windows and Macintosh: Visual QuickStart Guide 2001 0201749653 1 2
Real World FreeHand 5.0/5.5 1996 0201883600 4 1
Sams Teach Yourself Macromedia Dreamweaver 3 in 24 Hours 2000 0672318830 12 13
Sams Teach Yourself Macromedia Dreamweaver 4 in 24 Hours 2000 0672320428 12 13
Photoshop 6 Photo-Retouching Secrets 2001 0735711461 3 3
www.color 2000 0823058573 8 7
Www.Layout : Effective Design and Layout for the World Wide Web 2001 0823058581 8 8
1 2
First page Next page Last page

As you can see WBSP has created a default template for displaying all fields from table Titles in biblio.mdb. Since we did not define maximum number of records per page (WB_MaxRec) it used the default value of 20 records, and generated links to pages containing further records. It also displayed the WBSP logo at the bottom of the page.

Well, it is nice and easy solution but is not very useful, isn't it?

To make really useful example we will need an ordinary HTML page like this:

<html>
    <head>
    <title>Simple database example</title>
    </head>
    <body>
   
    </body>
</html>

The second step would be to add some WBSP lines (marked red):

[FormFields]
WB_Command=q
WB_Basename=biblio.mdb
WB_Rcdset=titles
wb_showlogo=F
<!--WB_BeginTemplate-->

<html>
    <head>
    <title>Simple database example</title>
    </head>
    <body>
    $wbdetail[t]
    </body>
</html>

If you open this page with your browser by typing it's address on your local server, you will see very little changes compared to first example - WBSP logo is not included in a page because we set WB_ShowLogo to false.

Now the third and final step for this example - setting the style for generated table (marked with blue):

 

[FormFields]
WB_Command=q
WB_Basename=biblio.mdb
WB_Rcdset=titles
wb_showlogo=F
[MsgAndLbl]
WB_Style=font-family:verdana;font-size:12px;color:#CC0000;

<!--WB_BeginTemplate-->

<html>
    <head>
    <style>
    .wbspttbl{
    border:1px solid #000000;
    font-family:verdana;
    font-size:12px;
    border-collapse:collapse;
    border-spacing:0px;
    }
    .wbspthdr{
    background-color:#CC0000;
    border:1px solid #000000;
    color:#C0C0C0;
    }
    .wbsptrow{
    background-color:#FFCC00;
    border:1px solid #000000;
    color:#0000CC;
    }
    </style>

    <title>Simple database example</title>
    </head>
    <body>
    $wbdetail[t]
    </body>
</html>

The result in the browser now should look something like this:

 

Title Year Published ISBN PubID AU_ID
McGraw-Hill's Encyclopedia of Networking & Telecommunications 2001 0072120053 10 10
Microsoft SMS Installer 2000 0072124474 10 9
Windows 2000 Iis 5.0 : A Beginner's Guide 2001 0072133724 9 9
Windows Nt Security Handbook 1996 0078822408 10 11
Microsoft Internet Information Server 4: the Complete Reference 1998 0078824575 10 10
Non-Designer's Scan and Print Book, The 1999 0201353946 1 2
Real World Adobe InDesign 1.5 2000 0201354780 1 1
HTML 4 for the World Wide Web: Visual Quickstart Guide 2000 0201354934 1 6
Real World Freehand 7 1997 0201688875 1 1
Netscape 3 for Macintosh Visual Quickstart Guide 1996 0201694085 1 6
Kai's Power Tools 3 for Windows Visual Quickstart Guide 1997 0201696681 1 2
InDesign 1.0/1.5 for Macintosh and Windows: Visual QuickStart Guide 2000 0201710366 1 2
Fireworks 4 for Windows and Macintosh Visual Quickstart Guide 2001 0201731339 1 2
Macromedia FreeHand 10 for Windows and Macintosh: Visual QuickStart Guide 2001 0201749653 1 2
Real World FreeHand 5.0/5.5 1996 0201883600 4 1
Sams Teach Yourself Macromedia Dreamweaver 3 in 24 Hours 2000 0672318830 12 13
Sams Teach Yourself Macromedia Dreamweaver 4 in 24 Hours 2000 0672320428 12 13
Photoshop 6 Photo-Retouching Secrets 2001 0735711461 3 3
www.color 2000 0823058573 8 7
Www.Layout : Effective Design and Layout for the World Wide Web 2001 0823058581 8 8
1 2
First page Next page Last page


As you can see we used css classes wbsptbl, wbspthdr and wbsptrow to format the table and for formatting navigation links we used WBSP variable WB_Style.